package com.cosmoplat.mom.iot.client.api.param;

import com.cosmoplat.mom.iot.client.IotApi;
import com.cosmoplat.mom.iot.client.constants.IotApis;
import com.cosmoplat.mom.iot.client.http.HttpRequest;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 分页查询设备历史数据参数
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class GetDeviceHistoryDataPageParam extends BaseIotPageParam {
    
    /**
     * 设备ID
     */
    private String deviceId;
    
    /**
     * 参数，多个参数使用,分割
     */
    private String deviceTelemetryProfileNames;
    
    /**
     * 开始时间戳
     */
    private String startTs;
    
    /**
     * 结束时间戳
     */
    private String endTs;
    

    @Override
    public void check() {
        super.check();
        // 设备ID必须提供
        if (deviceId == null || deviceId.isEmpty()) {
            throw new IllegalArgumentException("deviceId cannot be null or empty");
        }
    }
    
    @Override
    public IotApi api() {
        return IotApis.DEVICE_HISTORY_DATA_PAGE;
    }

    @Override
    public HttpRequest customizeHttpRequest(HttpRequest request) {
        return request.body(this)
                .addPathParam("deviceId", deviceId);
    }
}